package com.candy.th6;

public class Client extends Thread{
    //共享资源（银行账户）
    private Bank bank;
    //想要取款的金额
    private int want;

    public Client(String name, Bank bank, int want) {
        super(name);
        this.bank = bank;
        this.want = want;
    }

    @Override
    public void run () {
        int money;
        //当取款金额大于0时，为正常取款
        while((money=this.bank.getMoney(want))>0){
            System.out.println(this.getName()+"取到钱了");
        }
//        while (true){
//            if ((this.bank.getMoney(want))<=0){
//                break;
//            }
//        }
        //取款结束后，打印提示
        System.out.println("取款结束");
    }
}
